package com.mcxx.modules.minimumliving.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.mcxx.aspect.annotation.BizVisitLimit;
import com.mcxx.common.exception.BizException;
import com.mcxx.modules.minimumliving.service.BacklogService;
import com.mcxx.modules.miniSalvation.check.service.write.CheckWriteService;
import com.mcxx.modules.miniSalvation.family.dto.DemocraticAppraisalDTO;
import com.mcxx.modules.miniSalvation.family.entity.DemocraticAppraisalEntity;
import com.mcxx.modules.miniSalvation.family.service.read.AppraisalReadService;
import com.mcxx.modules.miniSalvation.family.service.write.DemocraticAppraisalWriteService;
import com.mcxx.modules.miniSalvation.order.dto.*;
import com.mcxx.modules.miniSalvation.order.param.OrderListSearchParam;
import com.mcxx.modules.miniSalvation.order.service.read.InHouseReadService;
import com.mcxx.modules.miniSalvation.order.service.read.OrderReadService;
import com.mcxx.modules.miniSalvation.order.service.read.StandardReadService;
import com.mcxx.modules.miniSalvation.salary.service.read.FamilySalaryReadService;
import com.mcxx.modules.miniSalvation.salary.service.write.FamilySalaryWriteService;
import com.mcxx.result.BaseResult;
import com.mcxx.service.DefaultRestService;
import com.mcxx.util.Constant;
import com.mcxx.util.FileExportUtil;
import com.yinhai.ta404.component.audit.vo.ExcelInfo;
import com.yinhai.ta404.core.restservice.annotation.RestService;
import com.yinhai.ta404.core.restservice.requestbean.PageParam;
import com.yinhai.ta404.core.restservice.resultbean.Page;
import com.yinhai.ta404.core.security.vo.UserAccountVo;
import com.yinhai.ta404.core.validate.annotation.V;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Validated
@Api("最低生活保障待办列表")
@RestService({"minimumliving/salvation/backlog/v2"})
public class SalvationBacklogController extends DefaultRestService {
    private static final Logger logger = LoggerFactory.getLogger(SalvationBacklogController.class);
    @Autowired
    private OrderReadService orderReadService;
    @Autowired
    private InHouseReadService inHouseReadService;
    @Autowired
    private DemocraticAppraisalWriteService democraticAppraisalWriteService;
    @Autowired
    private BacklogService backlogService;
    @Autowired
    private FamilySalaryReadService familySalaryReadService;
    @Autowired
    private AppraisalReadService appraisalReadService;
    @Autowired
    private StandardReadService standardReadService;
    @Autowired
    private CheckWriteService checkWriteService;
    @Autowired
    private FamilySalaryWriteService familySalaryWriteService;
    @Autowired
    ApplicationContext applicationContext;


    @PostMapping("getTownSalvationTodoList")
    @ApiOperation("查询乡镇待办列表")
    @BizVisitLimit(key = "minimumliving/salvation/backlog/v2/getTownSalvationTodoList", minPeriod = 3)
    public void getTownSalvationTodoList(OrderListSearchParam param, PageParam pageParam){
        logger.info("查询乡镇待办列表,查询参数：{},分页参数：{}", JSON.toJSONString(param),JSON.toJSONString(pageParam));
        param.setBusinessType(Constant.BusinessCode.DIBAO);
        Page page = orderReadService.getTownSalvationTodoList(param, pageParam, getCurUserAccount());
        setPageBean(page);
        logger.info("查询乡镇待办列表完成,结果：{}", JSON.toJSONString(page));
    }


    @PostMapping("sendCheck")
    @ApiOperation("发起核对")
    public void sendCheck(@V("notnull") @RequestPart List<CheckDTO> checkDTOList){
        logger.info("发起核对，参数是：{}", checkDTOList);
        Map<String, List<String>> rstMsgMap = backlogService.sendCheck(checkDTOList, getCurUserAccount(), Constant.BusinessCode.DIBAO,Constant.CheckType.NEW);
        Map<String, String> rstMap = this.packageSendCheckRst(rstMsgMap);
        setData("code", rstMap.get("code"));
        setData("msg", rstMap.get("msg"));
        logger.info("发起核对，结果是：{}", rstMap);
    }


    private Map<String, String> packageSendCheckRst( Map<String, List<String>> rstMsgMap){
        Map<String, String> rstMap = new HashMap<>();
        StringBuffer rstMsg = new StringBuffer();
        if(rstMsgMap.containsKey("noExistCert") == false && rstMsgMap.containsKey("canNotSendCheck") == false
                && rstMsgMap.containsKey("masterNumError") == false && rstMsgMap.containsKey("noReport") == false
                && rstMsgMap.containsKey("noExistsAssests") == false
                && rstMsgMap.containsKey("memberInfoError") == false
                && rstMsgMap.containsKey("noBackUpOrder") == false
                && rstMsgMap.containsKey("noIdCardSupport") == false
                && rstMsgMap.containsKey("memberNoExistCert") == false
                && rstMsgMap.containsKey("success") ){
             rstMap.put("code", "1");
             rstMap.put("msg", rstMsgMap.get("checkMsg").get(0));
             return rstMap;
        }else if(rstMsgMap.containsKey("noExistCert") == false && rstMsgMap.containsKey("canNotSendCheck") == false
                && rstMsgMap.containsKey("masterNumError") == false && rstMsgMap.containsKey("noReport") == false
                && rstMsgMap.containsKey("noExistsAssests") == false
                && rstMsgMap.containsKey("memberInfoError") == false
                && rstMsgMap.containsKey("noBackUpOrder") == false
                && rstMsgMap.containsKey("noIdCardSupport") == false
                && rstMsgMap.containsKey("memberNoExistCert") == false
                && rstMsgMap.containsKey("fail")){
            rstMap.put("code", "-1");
            rstMap.put("msg", "操作失败");
            return rstMap;
        }
        if(rstMsgMap.containsKey("masterNumError")){
            rstMsg.append("申请人身份证为：【").append(String.join(",",rstMsgMap.get("masterNumError"))).append("】户主信息错误，不能发起核对；\n");
        }
        if(rstMsgMap.containsKey("memberInfoError")){
            rstMsg.append("【").append(String.join(",",rstMsgMap.get("memberInfoError"))).append("】家庭存在未完善的成员信息，不能发起核对；\n");
        }
        if(rstMsgMap.containsKey("canNotSendCheck")){
            rstMsg.append("家庭【").append(String.join(",",rstMsgMap.get("canNotSendCheck"))).append("】核对中，不能发起核对；\n");
        }
        if(rstMsgMap.containsKey("noExistsAssests")){
            rstMsg.append("【").append(String.join(",",rstMsgMap.get("noExistsAssests"))).append("】家庭收入抵扣项未完善，不能发起核对；\n");
        }
        if(rstMsgMap.containsKey("noReport")){
            rstMsg.append("【").append(String.join(",",rstMsgMap.get("noReport"))).append("】已发起核对且无核对报告返回，不能继续发起核对；");
        }
        if(rstMsgMap.containsKey("noExistCert")){
            rstMsg.append("【").append(String.join(",",rstMsgMap.get("noExistCert"))).append("】不存在经济核对材料/户口本，不能发起核对；\n");
        }
        if(rstMsgMap.containsKey("noBackUpOrder")){
            rstMsg.append("【").append(String.join(",",rstMsgMap.get("noBackUpOrder"))).append("】没有生成诚信申请信息，不能发起核对；\n");
        }
        if(rstMsgMap.containsKey("memberNoExistCert")){
            rstMsg.append("【").append(String.join(",",rstMsgMap.get("memberNoExistCert"))).append("】家庭存在成员没有上传身份证，不能发起核对；\n");
        }
        if(rstMsgMap.containsKey("noIdCardSupport")){
            rstMsg.append("【").append(String.join(",",rstMsgMap.get("noIdCardSupport"))).append("】赡(抚)养人没有上传身份证，不能发起核对；\n");
        }
        if(rstMsgMap.containsKey("noAuthorSupport")){
            rstMsg.append("【").append(String.join(",",rstMsgMap.get("noAuthorSupport"))).append("】赡(抚)养人没有上传授权书，不能发起核对；\n");
        }
        if(rstMsgMap.containsKey("success")){
            rstMsg.append("【").append(String.join(",",rstMsgMap.get("success"))).append("】发起核对；\n");
        }
        if(rstMsgMap.containsKey("checkMsg")){
            rstMsg.append(rstMsgMap.get("checkMsg").get(0));
        }
        rstMap.put("code", "-1");
        rstMap.put("msg", rstMsg.toString());
        return rstMap;
    }


    @GetMapping("getCheckReportFile")
    @ApiOperation("查看核对报告")
    public void getCheckReportFile(HttpServletResponse response, @V({"notnull"}) String paramJson)  {
        HashMap<String, String> paramMap = JSONObject.parseObject(paramJson, new TypeReference<HashMap<String, String>>(){});
        if(!paramMap.containsKey("checkReportFileKey")){
            throw new BizException("-1", "参数checkReportFileKey为空");
        }
        byte[] bytes = backlogService.getCheckReportFile(paramMap.get("checkReportFileKey"),paramMap.get("fileType"));
        response.setContentType("application/pdf;charset=utf-8");
        try {
            response.getOutputStream().write(bytes);
            response.getOutputStream().flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    @PostMapping("completeCheck")
    @ApiOperation("完成核对，修改状态")
    public void completeCheck(@RequestPart List<String> orderIdList){
        logger.info("完成核对，修改状态：{}", orderIdList);
        checkWriteService.completeCheck(orderIdList);
        logger.info("完成核对，修改状态：结果：{}", true);
    }



    @PostMapping("isCanInHouse")
    @ApiOperation("判读是否可以发起入户调查")
    public void isCanInHouse(String orderId){
        logger.info("判读是否可以发起入户调查，参数orderId是：{}", orderId);
        backlogService.isCanInHouse(orderId, getCurUserAccount());
        logger.info("判读是否可以发起入户调查，结果：{}", true);
        setData(true);
    }


    @PostMapping("getInHouseRecord")
    @ApiOperation("根据orderId查询入户调查记录（乡镇/区县）")
    public void getInHouseRecord(@V("notnull") String orderId, @V("notnull") String areaLevel){
        logger.info("根据orderId查询入户调查记录，参数是：{}", orderId);
        OrderInHouseDTO orderInHouseDTO = inHouseReadService.queryLastInHouseRecord(orderId, areaLevel);
        setData(orderInHouseDTO);
        logger.info("根据orderId查询入户调查记录，结果是：{}", orderInHouseDTO);
    }


    @PostMapping("getLastInHouseRecord")
    @ApiOperation("根据orderId查询入户调查记录（乡镇/区县）")
    public void getLastInHouseRecord(@V("notnull") String orderId, @V("notnull") String areaLevel){
        logger.info("根据orderId查询入户调查记录，参数是：{}", orderId);
        OrderInHouseDTO orderInHouseDTO = inHouseReadService.queryLastInHouseRecord(orderId, areaLevel);
        setData(orderInHouseDTO);
        logger.info("根据orderId查询入户调查记录，结果是：{}", orderInHouseDTO);
    }


    @GetMapping("getInHouseListByOrderId")
    @ApiOperation("根据orderId查询入户调查记录列表（乡镇/区县）")
    public void getInHouseListByOrderId(String orderId){
        setData("data", inHouseReadService.selectListByOrderId(orderId, getCurUserAccount().getAreaLevel()));
    }






    @PostMapping("isCanDemocraticAppraisal")
    @ApiOperation("判断能否进行民主评议,已入户调查且没有计算待遇")
    public void isCanDemocraticAppraisal(@V("notnull") String orderId){
        logger.info("判断是否已经有入户调查，参数orderId是：{}", orderId);
        backlogService.isCanDemocraticAppraisal(orderId, getCurUserAccount());
        setData(true);
        logger.info("判断是否已经有入户调查，结果是：{}", true);
    }


    @GetMapping("getDemocracyAppraisal")
    @ApiOperation("根据orderId查询民主评议信息")
    public void getDemocracyAppraisal(@V("notnull") String orderId) {
        logger.info("根据orderId查询民主评议信息，参数，orderId:{}",orderId);
        DemocraticAppraisalDTO dto = appraisalReadService.getAppraisalByOrderIdForNew(orderId);
        setData(dto);
        logger.info("根据orderId查询民主评议信息，结果是:{}",dto);
    }


    @PostMapping("addDemocraticAppraisal")
    @ApiOperation("添加民主评议信息")
    public void addDemocraticAppraisal(@Valid DemocraticAppraisalEntity entity, @RequestPart List<String> orderCertIdList) {
        logger.info("添加民主评议信息，参数，entity:{}", entity);
        String appraisalId = backlogService.addDemocraticAppraisal(entity, orderCertIdList, getCurUserAccount());
        setData(appraisalId);
        logger.info("添加民主评议信息，结果是:{}", appraisalId);
    }


    @PostMapping("modifyDemocraticAppraisal")
    @ApiOperation("修改民主评议信息")
    public void modifyDemocraticAppraisal(@Valid DemocraticAppraisalEntity entity, @RequestPart List<String> orderCertIdList) {
        logger.info("编辑民主评议信息，参数是：{}", entity);
        democraticAppraisalWriteService.modifyDemocraticAppraisal(entity,orderCertIdList);
        setData(true);
        logger.info("编辑民主评议信息，结果是：{}", true);
    }





    @PostMapping("getStandardGear")
    @ApiOperation("根据家庭收入得到对应的档位")
    public void getStandardGear(@V("notnull") String standType, @V("notnull")  Double familyRevenue){
        logger.info("根据家庭收入得到对应的档位，参数，type:{}，家庭收入:{}", standType, familyRevenue);
        SalvationStandardDTO dto = standardReadService.getStandardGear(standType, getCurUserAccount(), familyRevenue, Constant.BusinessCode.DIBAO);
        setData(dto);
        logger.info("根据家庭收入得到对应的档位，结果是:{}", dto);
    }


    @PostMapping("isCanCalcFamilySalary")
    @ApiOperation("判断是否可以进行待遇计算")
    public void isCanCalcFamilySalary(@V("notnull") String orderId){
        logger.info("判断是否可以进行待遇计算，参数，orderId:{}", orderId);
        int rst = backlogService.isCanCalcFamilySalary(orderId);
        setData(rst);
        logger.info("判断是否可以进行待遇计算，结果是:{}", rst);
    }


    @PostMapping("changeFamnilySave")
    @ApiOperation("修改保障对象")
    public void changeFamnilySave(String orderId,String familyId,String memberId,String type,String isMaster){
        logger.info("修改保障对象，参数是orderSalary：{}", memberId);
        int rstMsg = backlogService.chengeMemberSaveObject(orderId,familyId,memberId,type,isMaster);
        setData(rstMsg);
        logger.info("修改保障对象，结果是：{}", rstMsg);
    }


    @PostMapping("changeDocHelpPoor")
    @ApiOperation("修改家庭成员的兜底类型")
    public void changeDocHelpPoor(String memberId,String docHelpPoor){
        logger.info("修改家庭成员的兜底类型，参数是memberId,doHelpPoor：{},{}", memberId,docHelpPoor);
        int rstMsg = backlogService.changDocHelpPoor(memberId,docHelpPoor);
        setData(rstMsg);
        logger.info("修改家庭成员的兜底类型，结果是：{}", rstMsg);
    }


    @PostMapping("saveFamilySalaryInfo")
    @ApiOperation("计算家庭救助待遇")
    public void saveFamilySalaryInfo(@RequestBody @V("notnull") OrderSalaryDTO orderSalary){

        logger.info("计算家庭救助待遇，参数是orderSalary：{}", orderSalary);
        orderSalary.setBusinessType(Constant.BusinessCode.DIBAO);
        BaseResult rstMsg = familySalaryWriteService.salaryDT(orderSalary,null, getCurUserAccount(),orderSalary.getType() == null ? 2 : 1,Constant.BusinessCode.DIBAO);
        setData(rstMsg);
        logger.info("计算家庭救助待遇，结果是：{}", rstMsg);
    }


    @PostMapping("getFamilySalaryInfo")
    @ApiOperation("得到家庭救助待遇")
    public void getFamilySalaryInfo(@V("notnull") String orderId){
        logger.info("得到家庭救助待遇，参数是orderId：{}", orderId);
        Map<String, Object> rstMap = familySalaryReadService.getFamilySalaryInfo(orderId,null,getCurUserAccount());
        setData("data", rstMap);
        logger.info("得到家庭救助待遇，结果是：{}", rstMap);
    }





    @PostMapping("isCanAudit")
    @ApiOperation("判断是否可以进行审核")
    public void isCanAudit(@V("notnull") String orderId, @V("notnull") String submitType){
        logger.info("判断是否可以进行审核，参数，orderId:{}", orderId);
        backlogService.isCanAudit(orderId, submitType, null, getCurUserAccount());
        logger.info("判断是否可以进行审核，结果是:{}", orderId);
    }


    @PostMapping("saveSalvationAudit")
    @ApiOperation("保存审核信息")
    public void saveSalvationAudit(OrderReviewDTO orderReviewDTO) {
        logger.info("保存审核信息，参数是：{}", orderReviewDTO);
        backlogService.saveSalvationAudit(orderReviewDTO, getCurUserAccount());
        setData(true);
        logger.info("保存审核信息，结果是：{}", true);
    }


    @PostMapping("modifySalvationAudit")
    @ApiOperation("编辑审核信息")
    public void modifySalvationAudit(OrderReviewDTO orderReviewDTO) {
        logger.info("编辑审核信息，参数是：{}", orderReviewDTO);
        backlogService.saveSalvationAudit(orderReviewDTO, getCurUserAccount());
        setData(true);
        logger.info("编辑审核信息，结果是：{}", true);
    }


    @PostMapping("getSalvationAudit")
    @ApiOperation("查询审核信息")
    public void getSalvationAudit(@V("notnull") String orderId) {
        logger.info("查询审核信息，参数是：{}", orderId);
        BaseResult<OrderDetailDTO>  rstMsg = backlogService.getOrderDetail(orderId, Constant.CheckDatailStatus.he);
        setData(rstMsg);
        logger.info("查询审核信息，结果是：{}", rstMsg);
    }

    @PostMapping("getInforToAudit")
    @ApiOperation("查询信息去审核")
    public void getInforToAudit(@V("notnull") String orderId){
        logger.info("审核前查询信息,参数是:{},{}",orderId);
        Map<String,Object> resMap= backlogService.getInfoBeforeAudit(orderId);
        setData("data",resMap);
        logger.info("审核前查询信息，结果是{}",resMap);

    }


    @PostMapping("submitSalvationRequest")
    @ApiOperation("上报救助申请")
    public void submitSalvationRequest(@V("notnull") OrderReviewDTO orderReviewDTO) {
        logger.info("上报救助申请，参数是：{}", orderReviewDTO);
        int rstFlag = backlogService.submitSalvationRequest(orderReviewDTO, getCurUserAccount());
        setData(true);
        logger.info("上报救助申请，结果是：{}", rstFlag);
    }


    @PostMapping("submitSalvationAuditBatch")
    @ApiOperation("批量上报")
    public void submitSalvationAuditBatch(@RequestPart List<String> orderIdList) {
        logger.info("批量上报，参数是：{}", orderIdList);
        Map<String, List<String>> stringListMap = backlogService.exceBatchReport(orderIdList,getCurUserAccount());
        if(stringListMap.isEmpty()){
            setData("success");
        }else{
            setData("用户【"+String.join("," , stringListMap.get("noExistState"))+"】状态不是待上报，不能操作");
        }
        logger.info("批量上报，结果是：{}", stringListMap);
    }




    @PostMapping("getSalvationPrintReport")
    @ApiOperation("查询救助打印书信息")
    public void getSalvationPrintReport(@V("notnull") String orderId) {

    }




    @PostMapping("backSalvationRequest")
    @ApiOperation("撤销救助申请")
    public void backSalvationRequest(@V("notnull") String orderId,@V("notnull") String revokeReason) {
        logger.info("撤销回退救助申请，参数是：{},申请原因：{}", orderId,revokeReason);
        backlogService.cancelSalvationRequestTown(orderId,revokeReason,getCurUserAccount());
        setData(true);
        logger.info("撤销回退救助申请，结果是：{}", true);
    }





    @PostMapping("cancelSalvationRequest")
    @ApiOperation("删除救助申请")
    public void cancelSalvationRequest(@RequestPart List<String> orderIdList) {
        logger.info("删除救助申请，参数是：{}", orderIdList);
        Map<String, List<String>> stringListMap = backlogService.cancelSalvationRequestTowns(orderIdList, getCurUserAccount());
        if(stringListMap.isEmpty()){
            setData("success");
        }else{
            setData("用户【"+String.join("," , stringListMap.get("noExistState"))+"】状态无法删除");
        }
        logger.info("删除救助申请，结果是：{}", stringListMap);
    }






    @PostMapping("getCountySalvationTodoList")
    @ApiOperation("获取区县待办列表")
    public void getCountySalvationTodoList(OrderListSearchParam param, PageParam pageParam){

        UserAccountVo userAccountVo = getCurUserAccount();

        param.setBusinessType(Constant.BusinessCode.DIBAO);
        Page page = orderReadService.getNoFinishOrderCounty(param, pageParam, userAccountVo);
        this.setPageBean(page);
    }





    @PostMapping("isCanInHouseCounty")
    @ApiOperation("区县-判读是否可以发起入户调查")
    public void isCanInHouseCounty(String orderId){
        logger.info("区县-判读是否可以发起入户调查，参数orderId是：{}", orderId);

        UserAccountVo userAccountVo = getCurUserAccount();
        backlogService.isCanInHouseCounty(orderId,userAccountVo);
        logger.info("区县-判读是否可以发起入户调查，结果：{}", 1);
        setData(1);
    }


    @PostMapping("isCanAuditCounty")
    @ApiOperation("区县-判断是否可以审批")
    public void isCanAuditCounty(String orderId){
        logger.info("区县-判断是否可以审批，参数orderId是：{}",orderId);
        backlogService.isCanAuditCounty(orderId, getCurUserAccount());
        logger.info("区县-判断是否可以审批，结果：{}", true);
        setData(true);
    }


    @PostMapping("modifyInHouseRecordCounty")
    @ApiOperation("更新入户调查信息")
    public void modifyInHouseRecordCounty(OrderInHouseDTO orderInHouse, @RequestPart List<String> orderCertIdList){
        logger.info("更新入户调查信息，参数是：{}", orderInHouse);
        int rst = backlogService.modifyInHouseRecordCounty(orderInHouse,orderCertIdList, getCurUserAccount());
        setData(rst);
        logger.info("保存入户调查信息，结果是：{}", rst);
    }


    @PostMapping("confirmInhouseRecordCounty")
    public void confirmInhouseRecordCounty(@V("notnull") OrderInHouseDTO orderInHouse, @V("notnull") @RequestPart List<String> orderCertIdList){
        logger.info("区县结束入户调查信息，参数是：{}", orderInHouse);
        String inhouseId = backlogService.confirmInhouseRecordCounty(orderInHouse,orderCertIdList, getCurUserAccount());
        setData(inhouseId);
        logger.info("区县结束入户调查信息，结果是：{}", true);
    }


    @PostMapping("queryReportDetail")
    @ApiOperation("区县-获取乡镇上报信息")
    public void queryReportDetail(String orderId){
        logger.info("区县-获取乡镇上报信，参数orderId是：{}", orderId);
        Map<String, Object> rstMap = backlogService.queryReportDetail(orderId);
        setData("data", rstMap);
        logger.info("区县-获取乡镇上报信息，结果：{}", rstMap);
    }







    @PostMapping("getFamilySalaryInfoCounty")
    @ApiOperation("得到家庭救助待遇")
    public void getFamilySalaryInfoCounty(String orderId){
        logger.info("得到家庭救助待遇，参数是orderId：{}", orderId);
        Map<String, Object> rstMap = familySalaryReadService.getFamilySalaryInfo(orderId,null,getCurUserAccount());
        setData("data", rstMap);
        logger.info("得到家庭救助待遇，结果是：{}", rstMap);
    }


    @PostMapping("confirmFamilySalaryInfo")
    @ApiOperation("确认家庭救助待遇")
    public void confirmFamilySalaryInfo( @RequestPart OrderSalaryDTO orderSalary, @RequestPart Map<String, String> memberMap){
        logger.info("计算家庭救助待遇，参数是orderSalary：{},familyMemberLMap:{}", orderSalary,memberMap);
        BaseResult<Boolean> rstMsg = backlogService.confirmFamilySalaryInfo(orderSalary, memberMap, getCurUserAccount());
        setData(rstMsg);
        logger.info("计算家庭救助待遇，结果是：{}", rstMsg);
    }






    @PostMapping("getSalvationApprove")
    @ApiOperation("查询审批信息")
    public void getSalvationApprove(@V("notnull") String orderId) {
        logger.info("查询审批信息，参数是：{}", orderId);
        BaseResult<OrderApproveDTO>  rstMsg = backlogService.getSalvationApprove(orderId);
        setData(rstMsg);
        logger.info("查询审批信息，结果是：{}", rstMsg);
    }


    @PostMapping("approveSalvationRequest")
    @ApiOperation("审批救助申请")
    public void approveSalvationRequest(OrderApproveDTO orderApproveDTO){
        logger.info("审批救助申请，参数是：{}", orderApproveDTO);
        String remindBankInfo = backlogService.approveSalvationRequest(orderApproveDTO, getCurUserAccount());
        setData(remindBankInfo);
        logger.info("审批救助申请，结果是：{}", true);
    }


    @PostMapping("saveApproveSalvation")
    @ApiOperation("暂存审批信息")
    public void saveApproveSalvation(OrderApproveDTO orderApproveDTO){
        logger.info("暂存审批信息，参数是：{}", orderApproveDTO);
        backlogService.saveApproveSalvation(orderApproveDTO, getCurUserAccount());
        setData(true);
        logger.info("暂存审批信息，结果是：{}", true);
    }




    @PostMapping("getInhouseRatio")
    @ApiOperation("查询入户抽查率")
    public void getInhouseRatio(OrderListSearchParam orderParam){
        logger.info("查询入户抽查率,参数是{}",orderParam);
        Map res = orderReadService.getInhouseRatio(orderParam,getCurUserAccount());
        setData(res);
        logger.info("查询入户抽查率,结果是：{}",res);
    }

    @PostMapping("isCanUploadCheckFile")
    @ApiOperation("是否可以上传核对文件")
    public void isCanUploadCheckFile(String familyId,String orderId){
        logger.info("是否可以上传核对文件,参数是{},{}",familyId,orderId);
        backlogService.isCanUploadCheckFile(familyId,orderId);
        logger.info("是否可以上传核对文件：{}",1);
    }

    @PostMapping("uploadCheckFile")
    @ApiOperation("上传核对文件")
    public void uploadCheckFile(@RequestParam("file")MultipartFile[] file, String orderId,String reason){
        logger.info("上传核对文件,参数是{}",orderId);
        int rst = backlogService.uploadCheckFile(file,orderId,reason,getCurUserAccount().getAreaCode());
        logger.info("上传核对文件,结果是：{}",rst);
    }


    @PostMapping("downLoadTownSalvation")
    @ApiOperation(value="导出低保乡镇待办信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,notes="导出低保乡镇已办信息")
    public void downLoadTownSalvation(HttpServletResponse response, @RequestBody OrderListSearchParam param)throws IOException {
        logger.info("开始导出低保乡镇已办信息，参数是：{}", param);
        param.setBusinessType(Constant.BusinessCode.DIBAO);
        ExcelInfo excelInfo = backlogService.exportTownSalvation(param,getCurUserAccount());
        if(null != excelInfo){
            FileExportUtil.exportFileResponse(response, excelInfo, getCurUserAccount().getAreaName());
//            ZipInfoUtil.exportZipResponse(response, excelInfo, this.getCurUserId());
        }
        logger.info("开始导出低保乡镇待办信息，查询结果是：{}", excelInfo);
    }


    @PostMapping("downLoadCountySalvation")
    @ApiOperation(value="导出低保区县待办信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,notes="导出低保乡镇已办信息")
    public void downLoadCountySalvation(HttpServletResponse response, @RequestBody OrderListSearchParam param)throws IOException {
        logger.info("开始导出低保区县已办信息，参数是：{}", param);
        param.setBusinessType(Constant.BusinessCode.DIBAO);
        ExcelInfo excelInfo = backlogService.exportTownSalvation(param,getCurUserAccount());
        if(null != excelInfo){
            FileExportUtil.exportFileResponse(response, excelInfo, getCurUserAccount().getAreaName());
//            ZipInfoUtil.exportZipResponse(response, excelInfo, this.getCurUserId());
        }
        logger.info("开始导出低保区县待办信息，查询结果是：{}", excelInfo);
    }


    @PostMapping("sendBackSys")
    @ApiOperation("发起退回")
    public void sendBackSys(@V("notnull") String orderId,String content){
        logger.info("发起退回，参数是：{}", orderId);
        backlogService.sendBackSys(orderId, content, getCurUserAccount(), Constant.BusinessCode.DIBAO);
        setData(true);
    }

    @PostMapping("decideIncome")
    @ApiOperation("判断家庭成员收入是否为空")
    public void decideIncome(@V("notnull") String orderId,@V("notnull") String familyId){
        logger.info("判断家庭成员收入是否为空,参数是{}",orderId,familyId);
        int rst = backlogService.decideIncome(orderId,familyId);
        setData(rst);
        logger.info("判断家庭成员收入是否为空,结果是：{}",rst);
    }
}
